import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import ShouLayout from '@/views/shouye/index.vue'
/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path:'/shouye/news/newsDetail',
    component: () => import('@/views/shouye/subcontent/newsDetail'),
    hidden: true
  },
  {
    path:'/shouye/goods/goodsDetail',
    component: () => import('@/views/shouye/subcontent/goodsDetail'),
    hidden: true
  },
  {
    path:'/shouye/goods/buyGoodsInfo',
    component: () => import('@/views/shouye/subcontent/buyGoodsInfo'),
    hidden: true
  },

  {
    path:'/shouye',
    component: ShouLayout,
    name: '首页',
    redirect: '/shouye/news',
    meta: { title: '首页' },
    hidden: true,
    children: [
      {
        path: 'news',
        name: '新闻',
        component: () => import('@/views/shouye/subcontent/news'),
        meta: { title: '新闻' },
      },
      {
        path: 'userCentre',
        name: '个人中心',
        component: () => import('@/views/shouye/subcontent/userCentre'),
        meta: { title: '个人中心' },
        children: [
          {
            path: 'myOrder',
            name: '我的订单',
            component: () => import('@/views/shouye/subcontent/order.vue'),
            meta: { title: '我的订单', icon: 'table' },
            children: [
              {
                path: 'orderAll',
                name: '全部订单',
                component: () => import('@/views/shouye/subcontent/order/orderAll.vue'),
                meta: { title: '全部订单', icon: 'table' },
              },
              {
                path: 'waitPay',
                name: '待付款',
                component: () => import('@/views/shouye/subcontent/order/waitPay.vue'),
                meta: { title: '待付款', icon: 'table' },
              },
              {
                path: 'waitGoods',
                name: '待发货',
                component: () => import('@/views/shouye/subcontent/order/waitGoods.vue'),
                meta: { title: '待发货', icon: 'table' },
              },
              {
                path: 'waitPutGoods',
                name: '待收货',
                component: () => import('@/views/shouye/subcontent/order/waitPutGoods.vue'),
                meta: { title: '待收货', icon: 'table' },
              },
              {
                path: 'waitAppraise',
                name: '待评价',
                component: () => import('@/views/shouye/subcontent/order/waitAppraise.vue'),
                meta: { title: '待签收', icon: 'table' },
              },
            ]
          },
          {
            path: 'userInfo',
            name: '个人信息',
            component: () => import('@/views/shouye/subcontent/userInfo.vue'),
            meta: { title: '个人信息', icon: 'table' },
          }
        ]
      },
      {
        path: 'game',
        name: '游戏',
        component: () => import('@/views/shouye/subcontent/game'),
        meta: { title: '游戏' },
      },
      {
        path: 'nowPlayer',
        name: '现役选手',
        component: () => import('@/views/shouye/subcontent/nowPlayer'),
        meta: { title: '选手' },
      },
      {
        path: 'retirePlayer',
        name: '退役选手',
        component: () => import('@/views/shouye/subcontent/retirePlayer'),
        meta: { title: '退役选手' },
      },
      {
        path: 'match',
        name: '赛程',
        component: () => import('@/views/shouye/subcontent/match'),
        meta: { title: '赛程' },
      },
      {
        path: 'clue',
        name: '俱乐部',
        component: () => import('@/views/shouye/subcontent/clue'),
        meta: { title: '俱乐部' },
      },
      {
        path: 'ambitus',
        name: '周边',
        component: () => import('@/views/shouye/subcontent/ambitus'),
        meta: { title: '周边' },
      },
      {
        path: 'video',
        name: '视频播放',
        component: () => import('@/views/shouye/subcontent/video'),
        meta: { title: '视频播放' },
      },
    ]
  },
 
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/dashboard',
  //   children: [{
  //     path: 'dashboard',
  //     name: 'Dashboard',
  //     component: () => import('@/views/dashboard/index'),
  //     meta: { title: 'Dashboard', icon: 'dashboard' }
  //   }]
  // },

  {
    path: '/news',
    component: Layout,
    redirect: '/news/list',
    name: 'news',
    meta: { title: '新闻管理', icon: 'el-icon-message' },
    children: [
      {
        path: 'list',
        name: 'newsList',
        component: () => import('@/views/news/list.vue'),
        meta: { title: '新闻列表', icon: 'table' }
      },
      {
        path: 'create',
        name: 'newsCreate',
        component: () => import('@/views/news/form.vue'),
        meta: { title: '添加新闻', icon: 'tree' }
      },
      {
        path: 'edit/:id',
        name: 'newsUpdate',
        component: () => import('@/views/news/form.vue'),
        meta: { title: '编辑新闻' },
        hidden: true
      }
    ]
  },
  {
    path: '/game',
    component: Layout,
    redirect: '/game/list',
    name: 'game',
    meta: { title: '游戏管理', icon: 'el-icon-monitor' },
    children: [
      {
        path: 'list',
        name: 'gameList',
        component: () => import('@/views/game/list.vue'),
        meta: { title: '游戏列表', icon: 'table' }
      },
      {
        path: 'create',
        name: 'gameCreate',
        component: () => import('@/views/game/form.vue'),
        meta: { title: '添加游戏', icon: 'table' }
      },
      {
        path: 'edit/:id',
        name: 'gameUpdate',
        component: () => import('@/views/game/form.vue'),
        meta: { title: '编辑游戏' },
        hidden: true
      }
    ]
  },
  {
    path: '/player',
    component: Layout,
    redirect: '/player/nowPlayerList',
    name: 'player',
    meta: { title: '选手管理', icon: 'el-icon-s-custom' },
    children: [
      {
        path: 'nowPlayerList',
        name: 'nowPlayerList',
        component: () => import('@/views/player/nowPlayerList.vue'),
        meta: { title: '现役选手', icon: 'table' }
      },
      {
        path: 'retirePlayerList',
        name: 'retirePlayerList',
        component: () => import('@/views/player/retirePlayerList.vue'),
        meta: { title: '退役选手', icon: 'table' }
      },
      {
        path: 'playerPlaceList',
        name: 'playerPlaceList',
        component: () => import('@/views/player/playerPlaceList.vue'),
        meta: { title: '选手位置', icon: 'el-icon-place' }
      },
      {
        path: 'playerPlaceCreate',
        name: 'playerPlaceCreate',
        component: () => import('@/views/player/playerPlaceForm.vue'),
        meta: { title: '添加位置', icon: 'table' },
        hidden: true
      },
      {
        path: 'playerPlaceEdit/:id',
        name: 'playerPlaceEdit',
        component: () => import('@/views/player/playerPlaceForm.vue'),
        meta: { title: '修改位置', icon: 'table' },
        hidden: true
      },
      {
        path: 'playerCreate',
        name: 'playerCreate',
        component: () => import('@/views/player/playerForm.vue'),
        meta: { title: '添加选手', icon: 'table' },
        hidden: true
      },
      {
        path: 'playerEdit/:id',
        name: 'playerEdit',
        component: () => import('@/views/player/playerForm.vue'),
        meta: { title: '修改选手', icon: 'table' },
        hidden: true
      },
    ]
  },

  {
    path: '/honor',
    component: Layout,
    redirect: '/honor/honorList',
    name: 'honor',
    meta: { title: '历史荣誉', icon: 'el-icon-trophy' },
    children: [
      {
        path: 'honorList',
        name: 'honorList',
        component: () => import('@/views/honor/honorList'),
        meta: { title: '荣誉列表', icon: 'table' }
      },
      {
        path: 'honorCreate',
        name: 'honorCreate',
        component: () => import('@/views/honor/honorForm'),
        meta: { title: '添加荣誉', icon: 'table' },
        hidden: true
      },
      {
        path: 'honorEdit/:id',
        name: 'honorEdit',
        component: () => import('@/views/honor/honorForm'),
        meta: { title: '修改荣誉', icon: 'table' },
        hidden: true
      },
      {
        path: 'playerHonor',
        name: 'playerHonor',
        component: () => import('@/views/honor/playerHonor'),
        meta: { title: '选手荣誉', icon: 'tree' }
      },
      {
        path: 'honorCount',
        name: 'honorCount',
        component: () => import('@/views/honor/honorCount'),
        meta: { title: '荣誉统计', icon: 'el-icon-s-custom' }
      }
    ]
  },
  {
    path: '/match',
    component: Layout,
    redirect: '/match/matchList',
    name: 'match',
    children: [
      {
        path: 'matchList',
        name: 'matchList',
        component: () => import('@/views/match/list'),
        meta: { title: '赛程', icon: 'el-icon-stopwatch' },
      },
      {
        path: 'matchCreate',
        name: 'matchCreate',
        component: () => import('@/views/match/matchCreate'),
        meta: { title: '添加', icon: 'el-icon-s-help' },
        hidden: true
      },
      {
        path: 'matchEdit/:id',
        name: 'matchEdit',
        component: () => import('@/views/match/matchCreate'),
        meta: { title: '添加', icon: 'el-icon-s-help' },
        hidden: true
      },
    ]
  },

  {
    path: '/clue',
    component: Layout,
    redirect: '/clue/list',
    name: 'clue',
    meta: { title: '电竞俱乐部', icon: 'el-icon-office-building' },
    children: [
      {
        path: 'list',
        name: 'clueList',
        component: () => import('@/views/clue/list'),
        meta: { title: '俱乐部列表', icon: 'table' }
      },
      {
        path: 'create',
        name: 'clueCreate',
        component: () => import('@/views/clue/form'),
        meta: { title: '俱乐部添加', icon: 'tree' },
      },
      {
        path: 'edit/:id',
        name: 'clueUpdate',
        component: () => import('@/views/clue/form'),
        meta: { title: '俱乐部编辑', icon: 'tree' },
        hidden: true
      },
      {
        path: 'data',
        name: 'clueData',
        component: () => import('@/views/tree/index'),
        meta: { title: '俱乐部数据', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: '/system',
    children: [{
      path: 'index',
      name: 'index',
      component: () => import('@/views/system/index'),
      meta: { title: '系统设置', icon: 'el-icon-setting' }
    }],
    
  },
  {
    path: '/goods',
    component: Layout,
    redirect: '/goods/list',
    name: 'goods',
    children: [
      {
        path: 'list',
        name: 'goodsList',
        component: () => import('@/views/goods/list'),
        meta: { title: '周边', icon: 'el-icon-goods' }
      },
      {
        path: 'create',
        name: 'goodsCreate',
        component: () => import('@/views/goods/form'),
        meta: { title: '商品添加', icon: 'tree' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'goodsUpdate',
        component: () => import('@/views/goods/form'),
        meta: { title: '商品编辑', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    name: 'order',
    children: [
      {
        path: 'list',
        name: 'orderList',
        component: () => import('@/views/order/list'),
        meta: { title: '订单管理', icon: 'el-icon-s-order' }
      },
      {
        path: 'create',
        name: 'orderCreate',
        component: () => import('@/views/order/create'),
        meta: { title: '订单添加', icon: 'tree' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'orderUpdate',
        component: () => import('@/views/order/edit'),
        meta: { title: '订单编辑', icon: 'tree' },
        hidden: true
      }
    ]
  },

  // {
  //   path: '/form',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Form',
  //       component: () => import('@/views/form/index'),
  //       meta: { title: 'Form', icon: 'form' }
  //     }
  //   ]
  // },

  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //   name: 'Nested',
  //   meta: {
  //     title: 'Nested',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'Menu1',
  //       meta: { title: 'Menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'Menu1-1',
  //           meta: { title: 'Menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'Menu1-2',
  //           meta: { title: 'Menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'Menu1-2-1',
  //               meta: { title: 'Menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'Menu1-2-2',
  //               meta: { title: 'Menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'Menu1-3',
  //           meta: { title: 'Menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       name: 'Menu2',
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
